﻿///////////////////////////////////////////////////////////////////////////////
// File:        Types.hpp
// Author:      671643387@qq.com
// Description:
///////////////////////////////////////////////////////////////////////////////

#ifndef NIO_TYPES_HPP_
#define NIO_TYPES_HPP_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <boost/cstdint.hpp>

#if defined(__WINDOWS__)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinSock2.h>
#elif defined(__LINUX__)
#include <time.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#endif

namespace nio
{
    namespace base
    {
#if !defined(__64BIT__)
        typedef boost::uint32_t     size_t;
        typedef boost::int32_t      ssize_t;
#else
        typedef boost::uint64_t     size_t;
        typedef boost::int64_t      ssize_t;
#endif

#if defined(__WINDOWS__)
        typedef DWORD               time_t;
#elif defined(__LINUX__)
        typedef long                time_t;
#endif
    }

    namespace net
    {
#if defined(__WINDOWS__)
        typedef SOCKET              sock_t;
        typedef int                 socklen_t;
#elif defined(__LINUX__)
        typedef int     sock_t;

        const static int SOCKET_ERROR               = -1;
        const static int INVALID_SOCKET             = -1;
#endif
        const static int SOCKET_ERROR_WOULDBLOCK    = -500;
    }
}

#endif //NIO_TYPES_HPP_
